<?php
use Magento\Framework\App\Action\Action;
?>
<?php 
$_productCollection = $block->getProductCollection();
$pos = $block->getPositioned();
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
$_helper = $this->helper('Magento\Catalog\Helper\Output');
foreach ($_productCollection as $_product):
?>
<div class="item">
    <div class="img">
        <?php
        $productImage = $block->getImage($_product, 'category_page_grid');
        /*if ($pos != null) {
            $position = ' style="left:' . $productImage->getWidth() . 'px;'
                . 'top:' . $productImage->getHeight() . 'px;"';
        }*/
        ?>
        <?php if($block->isShow('thumb')): ?>
        <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1" title="<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>">
            <?php echo $productImage->toHtml(); ?>
        </a>
        <?php endif ?>
    </div>
    <div class="info">
        <strong class="product name product-item-name">
            <span></span>
            <a class="product-item-link"
               href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>">
                <?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
            </a>
        </strong>
            <?php  if($block->getReviewsSummaryHtml($_product, $templateType)){echo $block->getReviewsSummaryHtml($_product, $templateType); }else{?>
                <div class="product-reviews-summary short">
                    <div class="rating-summary">
                        <span class="label">
                            <span>Rating:</span>
                        </span>
                        <div class="rating-result" title="0%">
                            <span style="width:0%">
                                <span>0%</span>
                            </span>
                        </div>
                    </div>
                    <div class="reviews-actions">
                        <a class="action view">
                            <span>Reviews(0)</span>
                        </a>
                    </div>
                </div>
            <?php }?>
            <?php 
                $end = $this->helper('Mazentop\DiscountPrice\Helper\Data')->getProductDiscountEndDate($_product, $format = 'd F');
                if($end): 
                $today = time();
                $time = strtotime($end)-$today;
            ?>
            <span class="disview">
                <span class="clock"><img src="<?php echo $this->getViewFileUrl('images/clock.png'); ?>" id="clock-img" /></span>
                <span class="countdown" data-time="<?php echo $time?>"></span>
            </span>
            <?php else: ?>
            <span class="no-disview"></span>    
            <?php endif;?>
        <?php /* @escapeNotVerified */ echo $block->getProductPrice($_product);?>
        <?php $postParams = $block->getAddToCartPostParams($_product); ?>
<div class="product-item-inner">
    <div class="product actions product-item-actions">
                                        <div class="actions-primary">
                                            <?php if ($_product->isSaleable()): ?>
                                                <?php $postParams = $block->getAddToCartPostParams($_product); ?>
                                                <form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">
                                                    <input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
                                                    <input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
                                                    <?php echo $block->getBlockHtml('formkey')?>
                                                    <button type="submit"                                                          
                                                            class="action tocart primary">
                                                            <i class="fa fa-shopping-cart"></i>
                                                                            <span class="prompt"><?php /* @escapeNotVerified */ echo __('') ?></span>
                                                    </button>
                                                </form>
                                            <?php else: ?>
                                                <?php if ($_product->getIsSalable()): ?>
                                                    <div class="stock available"><span><?php /* @escapeNotVerified */ echo __('In stock') ?></span></div>
                                                <?php else: ?>
                                                    <div class="stock unavailable"><span><?php /* @escapeNotVerified */ echo __('Out of stock') ?></span></div>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
        <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
            <a href="#"
               class="action wishlist"                                                 
               aria-label="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
               data-post='<?php /* @escapeNotVerified */ echo $block->getAddToWishlistParams($_product); ?>'
               data-action="add-to-wishlist"
               role="button">
               <i class="fa fa-heart-o"></i>
                   <span class="prompt"><?php /* @escapeNotVerified */ echo __('') ?></span>
            </a>
        <?php endif; ?>
    </div>
</div>
<?php endforeach;?>